const state = {
    carList: [],
}
const mutations = {
    SET_CARLIST(state, payload) {
        state.carList.push({...payload, isCheck: true, buyNum: 1 })
    },
    SET_CAR_ISCHECK(state, id) {
        state.carList.forEach((ele, i) => {
            if (ele.id == id) {
                state.carList[i].isCheck = !ele.isCheck
            }
        })
    },
    DEL_CARLIST(state, id) {
        state.carList.forEach((ele, i) => {
            if (ele.id == id) {
                state.carList.splice(i, 1)
            }
        })
    },
    CHANGE_BUYNUM(state, id) {
        state.carList.forEach((ele, i) => {
            if (ele.id == id) {
                state.carList.buyNum = ele.buyNum
            }
        })
    },


}
const actions = {

}

export default {
    state,
    mutations,
    actions
}